﻿





using System.Collections.Generic;
using Microsoft.Xna.Framework;
using System.Diagnostics;

namespace Serialization.Script
{
    public class Path
    {
        private List<Vector2> PathPoints
        {
            get;
            set;
        }

        private int index;

        public Vector2 getNextDestination()
        {
            Debug.Assert(PathPoints != null);
            Vector2 returnVector;
            if (index < PathPoints.Count)
            {
                returnVector = PathPoints[index];
            }
            else
            {
                returnVector = PathPoints[PathPoints.Count - 1];
            }
            index ++;
            return returnVector;
        }

        public bool isFinished()
        {
            Debug.Assert(PathPoints != null);
            return PathPoints.Count <= index;
        }

        public void setStartPoint(Vector2 point)
        {
            Debug.Assert(PathPoints != null);
            Debug.Assert(PathPoints.Count > 0);
            Vector2 moveDistance = Vector2.Subtract(point, PathPoints[0]);
            for (int i = 0; i < PathPoints.Count; i++)
            {
                PathPoints[i] = Vector2.Add(PathPoints[i], moveDistance);
            }
        }

        public Path()
        {
            PathPoints = new List<Vector2>();
            index = 0;
        }

        public Path(List<Vector2> PathPoints)
        {
            this.PathPoints = PathPoints;
            index = 0;
        }
    }
}

